package com.hzhr.iot.device.dao;

import com.hzhr.iot.device.dao.mapper.custom.IotDeviceTypeEntityCustomMapper;
import com.hzhr.iot.device.dao.mapper.generator.IotDeviceTypeEntityMapper;
import com.hzhr.iot.device.entity.IotDeviceTypeEntity;
import com.hzhr.iot.device.entity.ext.IotDeviceTypeEntityExt;
import com.hzhr.iot.device.queryModel.custom.IotDeviceTypeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class IotDeviceTypeDao {
    @Autowired
    IotDeviceTypeEntityMapper iotDeviceTypeEntityMapper;
    @Autowired
    IotDeviceTypeEntityCustomMapper iotDeviceTypeEntityCustomMapper;

    public int insert(IotDeviceTypeEntity record) {
        if (record == null) return 0;
        int changeCount = iotDeviceTypeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = iotDeviceTypeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(IotDeviceTypeEntity record) {
        if (record == null) return 0;
        int changeCount = iotDeviceTypeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = iotDeviceTypeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public IotDeviceTypeEntity selectEntity(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<IotDeviceTypeEntity> selectEntityList(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<IotDeviceTypeEntity> entityList = new ArrayList<>();
        for (IotDeviceTypeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public IotDeviceTypeEntityExt selectExt(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<IotDeviceTypeEntityExt> selectExtList(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public IotDeviceTypeEntity selectDesEntity(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<IotDeviceTypeEntity> selectDesEntityList(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null) return null;
        List<IotDeviceTypeEntity> entityList = new ArrayList<>();
        for (IotDeviceTypeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public IotDeviceTypeEntityExt selectDesExt(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<IotDeviceTypeEntityExt> selectDesExtList(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<IotDeviceTypeEntityExt> extList = iotDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        return extList;
    }

    public int selectCount(IotDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = iotDeviceTypeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
